package com.itheima.mapper;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface CheckgroupCheckitemMapper {

    /**
     * 根据检查组id查询关联的检查项id
     * @param checkGroupId
     * @return
     */
    @Select("select checkitem_id from t_checkgroup_checkitem where checkgroup_id = #{checkGroupId}")
    List<Integer> findCheckItemIdsByCheckGroupId(Integer checkGroupId);


    /**
     * 根据检查组id插入关联的检查项
     * @param checkitemIds
     * @param checkGroupId
     */
    void add(List<Integer> checkitemIds, Integer checkGroupId);


    /**
     * 根据检查组id删除关联的检查项
     * @param checkgroupId
     */
    @Delete("delete from t_checkgroup_checkitem where checkgroup_id = #{checkgroupId}")
    void deleteByCheckGroupId(Integer checkgroupId);

    /**
     * 根据检查项id查询是否有检查组包含该检查项
     * @param checkitemId
     */
    @Select("select count(*) from t_checkgroup_checkitem where checkitem_id = #{checkitemId}")
    Long findCountByCheckItemId(Integer checkitemId);
}
